<?php
/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 2018/7/20
 * Time: 12:31
 */
namespace app\api\controller;

use phpspider\core\phpspider;
use phpspider\core\requests;
use phpspider\core\selector;
class Test
{
    public function index()
    {
        $url = "https://www.qiushibaike.com/";
        $html = requests::get($url);
//        $selector="//*[@id=\"qiushi_tag_120676383\"]/a[1]/div/span";
        $selector="//div[starts-with(@id, 'qiushi_tag_')]/a[1]/div/span";
        $result=selector::select($html,$selector);
        dump($result);
    }

    public function index2()
    {
        $url="http://www.866pic.com";

        $html=requests::get($url);
        //获取所有父级导航
//        $selector="//*[@id=\"top-content\"]/div[2]/a";
//        $res=selector::select($html,$selector);

        //父子导航
        $select2="//*[@id=\"top-content\"]/div[2]/div/div[2]/ul/li/a/span";
        $pid=selector::select($html,$select2);
        $cate=[];
        foreach ($pid as $k=>$v){
            //子导航
            $select3='//*[@id="top-content"]/div[2]/div/div[2]/ul/li['.($k+1).']/div/div[2]/ul/li/a';
            $res=selector::select($html,$select3);
            $cate[$v]=$res;

        }
        dump($cate);
    }


}